package de.riceman.simpleGo.commands;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.binding.form.FormModel;
import org.springframework.binding.form.HierarchicalFormModel;
import org.springframework.richclient.command.ActionCommand;
import org.springframework.richclient.dialog.TabbedDialogPage;
import org.springframework.richclient.form.FormModelHelper;

import de.riceman.simpleGo.main.HumanMoveSetup;
import de.riceman.simpleGo.view.dialogs.HumanMoveDialog;
import de.riceman.simpleGo.view.forms.HumanMoveForm;

/**
 * 
 * 
 * @author Mario Reissmann
 *
 */
public class HumanMoveCommand extends ActionCommand {

	private final Log logger = LogFactory.getLog(getClass());
	
	FormModel ownerFormModel;
	HumanMoveForm humanMoveForm;
	
	@Override
	protected void doExecuteCommand() {

		if( logger.isInfoEnabled() ) {
            logger.info("New HumanMove Dialog requested.");
        }
		
		final HumanMoveSetup humanMoveSetup = new HumanMoveSetup();
		
		ownerFormModel = FormModelHelper.createCompoundFormModel(humanMoveSetup);
		humanMoveForm = new HumanMoveForm(FormModelHelper.createChildPageFormModel((HierarchicalFormModel) ownerFormModel, null));
		
		final TabbedDialogPage compositePage = new TabbedDialogPage("moveProperties");
		compositePage.addForm(humanMoveForm);
		
		HumanMoveDialog dialog = new HumanMoveDialog(compositePage, humanMoveForm);
		dialog.showDialog();

	}

}
